package com.bwie.controller;

import com.bwie.pojo.TbActive;
import com.bwie.pojo.TbGroup;
import com.bwie.pojo.TbGroupActive;
import com.bwie.pojo.TbGroupJoin;
import com.bwie.service.*;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("team/index")
public class IndexController {

    @Autowired
    TbActiveService tbActiveService;

    @Autowired
    TbOrderService tbOrderService;

    @Autowired
    TbGroupService tbGroupService;

    @Autowired
    TbGroupActiveService tbGroupActiveService;

    @Autowired
    TbGroupJoinService tbGroupJoinService;

    @Autowired
    TbDictService tbDictService;




    @ApiOperation("图片上传")
    @PostMapping("/uploadImage")
    public R uploadImage(@RequestPart("file") MultipartFile file){
        return tbActiveService.uploadImage(file);
    }

    @ApiOperation("拼团分页")
    @PostMapping("/GroupPageList")
    public R GroupPageList(@RequestBody PageInfoVo pageInfoVo){
        return tbGroupService.TeamActivePageList(pageInfoVo);
    }

    @ApiOperation("添加拼团")
    @PostMapping("/saveGroup")
    public R saveGroup(@RequestBody TbGroup group){
        return tbGroupService.instr(group);
    }

//    @ApiOperation("参与活动分页")
//    @PostMapping("/ActiveJoinPageList")
//    public R TemJoinPageList(@RequestBody PageInfoVo pageInfoVo){
//        return tbActiveService.TeamJoinPageList(pageInfoVo);
//    }

    @ApiOperation("参与活动")
    @PostMapping("/groupJoinPageList")
    public R groupJoinPageList(@RequestBody PageInfoVo pageInfoVo){
        return tbGroupJoinService.TeamJoinPageList(pageInfoVo);
    }

    @ApiOperation("添加参与活动")
    @PostMapping("/saveGroupAct")
    public R saveGroupAct(@RequestBody TbGroupJoin groupJoin){
        return tbGroupJoinService.instr(groupJoin);
    }

    @ApiOperation("删除参与活动柜")
    @PostMapping("/deleteJoinActive/{joinId}")
    public R deleteJoinActive(@PathVariable(name = "joinId") Integer joinId){
        return tbGroupJoinService.deleteJoinActive(joinId);
    }

    @ApiOperation("字段展示")
    @PostMapping("/getDictList")
    public R getDictList(){
        return tbDictService.getDictList();
    }
//    @ApiOperation("添加")
//    @PostMapping("/activeAdd")
//    public R activeAdd(@RequestBody TbActive tbActive){
//        return tbActiveService.insert(tbActive);
//    }

//

//

    @ApiOperation("拼团活动")
    @PostMapping("/groupActive")
    public R groupActive(@RequestBody PageInfoVo pageInfoVo) {
        return tbGroupActiveService.groupActive(pageInfoVo);
    }

    @ApiOperation("添加拼团")
    @PostMapping("/addGroup")
    public R addGroup(@RequestBody TbGroupActive tbGroupActive){
        return tbGroupActiveService.addGroup(tbGroupActive);
    }

    @ApiOperation("我的拼团")
    @PostMapping("/myGroup")
    public R myGroup(){
        return tbGroupService.myGroup();
    }
}
